# Maintainer: Sundaram Ramaswamy <legends2k@yahoo.com>

pkgname=bc
pkgver=1.06
pkgrel=2
pkgdesc="An arbitrary precision calculator language"
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/bc"
license=('GPL')
depends=('gcc' 'libreadline' 'ncurses')
builddepends=('libreadline-devel' 'ncurses-devel')
source=(http://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz
        0001-Fix-readline-prototype.patch)
sha1sums=('c8f258a7355b40a485007c40865480349c157292'
          '64f51317b830d6fa9bdb9712ccb0b946715d42c1')

prepare () {
  cd "${srcdir}"/${pkgname}-${pkgver}
  patch -p1 -i "${srcdir}"/0001-Fix-readline-prototype.patch
}

build () {
  [ -d ${srcdir}/build-${CHOST} ] && rm -rf ${srcdir}/build-${CHOST}
  mkdir ${srcdir}/build-${CHOST} && cd ${srcdir}/build-${CHOST}
  
  ../${pkgname}-${pkgver}/configure \
    --prefix=/usr \
    --build=${CHOST} \
    --host=${CHOST} \
    --with-readline

  make
}

check () {
  cd build-${CHOST}
  echo "quit" | ./bc/bc -l "${srcdir}"/${pkgname}-${pkgver}/Test/checklib.b # 10 failures
}

package () {
  cd build-${CHOST}
  make prefix="${pkgdir}/usr" install
}
